#ifndef	THREADPOOL_HPP__
# define	THREADPOOL_HPP__

# include	<iostream>
# include	<vector>

# include	"SafeQueue.hpp"
# include	"Thread.hpp"
# include	"CondVar.hpp"
# include	"Task.hpp"

class ThreadPool
{
public:
  static const int		NB_THREAD_MIN = 2;

public:
  typedef	std::vector<Thread *>	Threads;
  typedef	SafeQueue<Task>		Tasks;

public:
  ThreadPool(int = NB_THREAD_MIN);
  virtual ~ThreadPool();

  virtual bool			create() = 0;
  virtual void			destroy() = 0;
  bool				assignTask(Task *);
  virtual void			executeTasks() = 0;
  unsigned int			getPoolSize() const;
  unsigned int			getNbTask() const;

protected:
  Tasks				_tasks;
  Threads			_threads;
  unsigned int			_nbThread;
  int				_remainingTask;
  CondVar			_cvar;

private:
  ThreadPool(ThreadPool const&);
  ThreadPool	&operator=(ThreadPool const&) { return (*this); }
};

#endif	/* !THREADPOOL_HPP__ */
